package api

import (
	"CDSystem/v2/model"
	"CDSystem/v2/service"
	"log"
	"net/http"

	"github.com/gin-gonic/gin"
)

func (*ApiHandler) InferImage(c *gin.Context) {
	var ir model.InferRequest
	if err := c.ShouldBindJSON(&ir); err == nil {
		//log.Println(ir)
		cRes, err := service.InferToApi(ir)
		if err != nil {
			log.Println(err)
			c.JSON(http.StatusNoContent, cRes)
		} else {
			c.JSON(http.StatusOK, cRes)
		}
	} else {
		log.Println(err)
		c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
	}
}
